package com.example.supermarket.service.impl;

import com.example.supermarket.mapper.UserMapper;
import com.example.supermarket.pojo.User;
import com.example.supermarket.service.UserService;
import com.example.supermarket.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(User user) {
        return userMapper.login(user);
    }

    @Override
    public User findRole() {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer userId=(Integer) map.get("userId");
        User u=userMapper.findRole(userId);
        return u;
    }
}
